package main
import (
	"fmt"
)

type A struct{
	a int
	b string
}

type B struct{
	c int
	d string
	a int
}

type C struct{
	A
	B
	int
}

type C1 struct{
	*A
	*B
	int
}

type D struct{
	a int
	b string
	c B 	//组合模式
}

func main(){
	// c := C{A{10,"aaa"},B{20,"bbb",50},888}
	c := C{
		A{
			a : 10,
			b : "aaa",
			},
		B{
			c : 20,
			d : "bbb",
			a : 50,
		},
		888}
	fmt.Println(c.b)
	fmt.Println(c.d)
	fmt.Println(c.A.a)
	fmt.Println(c.B.a)
	fmt.Println(c.int)

	c1 := C1{&A{10,"aaa"},&B{20,"bbb",50},888}

	fmt.Println(c1)
	fmt.Println(*c1.A)	//匿名结构体可以为指针
	fmt.Println(*c1.B)	//匿名结构体可以为指针

	d := D{10,"ooo",B{10,"bbb",20}}
	fmt.Println(d)
	fmt.Println(d.c)
	fmt.Println(d.c.d)
}